<?php
defined('_JEXEC') or die;

// Getting params from template
$params = JFactory::getApplication()->getTemplate(true)->params;

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;

// Detecting Active Variables
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$task = $app->input->getCmd('task', '');
$itemid = $app->input->getCmd('Itemid', '');
$sitename = $app->getCfg('sitename');
if ($this->params->get('sitetitle')) {
    $sitename = $this->params->get('sitetitle');
}

JHtml::_('bootstrap.framework');
$doc->addScript('templates/' . $this->template . '/js/template.js');
$doc->addScript('templates/' . $this->template . '/js/bootstrap.js');
$doc->addScript('templates/' . $this->template . '/js/lib.js');
$doc->addScript('templates/' . $this->template . '/js/jlibs.js');
$doc->addScript('templates/' . $this->template . '/js/common.js');

$doc->addStyleSheet('templates/' . $this->template . '/css/template.css');
$doc->addStyleSheet('templates/' . $this->template . '/css/bootstrap.min.css');
$doc->addStyleSheet('templates/' . $this->template . '/css/animation.css');
$doc->addStyleSheet('templates/' . $this->template . '/css/font-awesome.min.css');
//JHtml::_('bootstrap.loadCss', false, $this->direction);
$doc->addStyleSheet('templates/' . $this->template . '/css/styles.css');
$doc->addStyleSheet('templates/' . $this->template . '/css/styles-ie.css');
$displayoption = $this->params->get('displayoption');
$logo = '<div class="logo">';
if ($this->params->get('logoFile') && in_array(1, $displayoption)) {
    $width = 'width= "auto"';
    if ($this->params->get('logoWidth')) {
        $width = 'width= "' . $this->params->get('logoWidth') . '"';
    }
    $logo .= '<a class="logoImage" href="' . JUri::root() . '" title="' . $sitename . '"><img id="imgLogo" alt="' . $sitename . '"  ' . $width . '  src="' . JUri::root() . '/' . $this->params->get('logoFile') . '" />';
}
if ($this->params->get('sitetitle') && in_array(2, $displayoption)) {
    $logo .= '<h1 class="sitename">' . $sitename . '</h1>';
}
if ($this->params->get('sitedescription') && in_array(3, $displayoption)) {
    $logo .= '<h2 class="sitedesc">' . $this->params->get('sitedescription') . '</h2>';
}
$logo .= '</a></div>';
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <jdoc:include type="head" />
        <?php
        $stylebg = '';
        if ($this->params->get('templateBackgroundColor')) {
            $stylebg = 'background:' . $this->params->get('templateBackgroundColor');
        } else {
            $stylebg = 'background:#fff';
        }
        if ($this->params->get('templateBackgroundImage')) {
            $stylebg .= ' url("' . JUri::root() . '/' . $this->params->get('templateBackgroundImage') . '") ';
            switch ($this->params->get('bgrepeat')) {
                case 0:
                    $stylebg .=' no-repeat ';
                    break;
                case 1:
                    $stylebg .=' repeat-x ';
                    break;
                case 2:
                    $stylebg .=' repeat-y ';
                    break;
                case 3:
                    $stylebg .=' repeat ';
                    break;
                default :
                    $stylebg .=' repeat ';
                    break;
            }
            switch ($this->params->get('bgposition')) {
                case 0:
                    $stylebg .=' top left ';
                    break;
                case 1:
                    $stylebg .=' top right ';
                    break;
                case 2:
                    $stylebg .=' fixed ';
                    break;
                case 3:
                    $stylebg .=' cover ';
                    break;
                default :
                    $stylebg .=' top left ';
                    break;
            }
        }
        ?>
        <?php
        // Template color
        if ($this->params->get('templateColor')) {
            ?>
            <style type="text/css">
                body.site{border-top: 3px solid #fff;<?php echo $stylebg ?>}
                h1.title,h2.title,h3.title,h4.title,h5.title,h6.title,.site-title,.sitename{color: <?php echo $this->params->get('templateColor'); ?>}
                a{color: <?php echo $this->params->get('templateColor'); ?>;}
                .navbar-inner, .nav-list > .active > a, .nav-list > .active > a:hover, .dropdown-menu li > a:hover, .dropdown-menu .active > a, .dropdown-menu .active > a:hover, .nav-pills > .active > a, .nav-pills > .active > a:hover,
                .btn-primary{background: <?php echo $this->params->get('templateColor'); ?>;}
            </style>
            <?php
        }
        ?>
        <!--[if lt IE 9]>
                <script src="<?php echo $this->baseurl ?>/media/jui/js/html5.js"></script>
        <![endif]-->
    </head>

    <body class="site <?php
    echo $option
    . ' view-' . $view
    . ($layout ? ' layout-' . $layout : ' no-layout')
    . ($task ? ' task-' . $task : ' no-task')
    . ($itemid ? ' itemid-' . $itemid : '')
    . ' ' . $this->language;
    ?>">
        <header class="header">
            <div class="container-outter">

            </div>
            <div class="container-inner">
                <div class="container">
                    <?php echo $logo; ?>
                    <?php if ($this->countModules('position-1')) : ?>
                        <nav class="navigation" role="navigation">
                            <jdoc:include type="modules" name="position-1" style="none" />
                        </nav>
                    <?php endif; ?>
                </div>
            </div>
            <div class="container-outter">

            </div>
        </header>
        <main class="main">
            <div class="container-outter">

            </div>
            <div class="container-inner">
                <div class="container">
                    <jdoc:include type="message" />
                    <jdoc:include type="component" />
                </div>
            </div>
            <div class="container-outter">

            </div>
        </main>
        <footer class="footer" role="contentinfo">
            <div class="container-outter">

            </div>
            <div class="container-inner">
                <div class="container">
                </div>
            </div>
            <div class="container-outter">

            </div>
        </footer>
        <jdoc:include type="modules" name="debug" style="none" />
    </body>
</html>
